﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.filehandle
{
    public partial class collection : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["MemberID"] == null)
            {
                ChangeHope.WebPage.Script.AlertAndGoBack("温馨提示：登录以后才能加入收藏！");
            }
            YXShop.BLL.Accessories.Collection bll = new YXShop.BLL.Accessories.Collection();
            YXShop.Model.Accessories.Collection model = new YXShop.Model.Accessories.Collection();
            int id = ChangeHope.WebPage.PageRequest.GetQueryInt("q_productid");
            ChangeHope.DataBase.DataByPage dataPage = bll.GetList(" 1=1 and collectionid=" + id + " and collectionuid=" + Session["MemberID"].ToString());
            if (dataPage.DataReader != null && dataPage.DataReader.FieldCount > 0)
            {
                ChangeHope.WebPage.Script.AlertAndGoBack("温馨提示：您已经收藏该商品！");
            }
            else
            {
                model.CollectionId = ChangeHope.WebPage.PageRequest.GetQueryInt("q_productid");
                model.CollectionType = 2;
                model.CollectionName = Session["MemberName"].ToString();
                model.CollectionUid = Convert.ToInt32(Session["MemberID"].ToString());
                model.CollectionDate = DateTime.Now;
                if (bll.Add(model) != 0)
                {
                    ChangeHope.WebPage.Script.AlertAndGoBack("温馨提示：收藏成功.");
                }
            }         
        }
    }
}
